import java.io.FileReader;
import java.io.FileWriter;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

import beans.Community;

public class pruebaPersistLista {


	
	public static void main(String[] args) {
		Community community = new Community();
		
		try{
			
			
			//lista a XML
			JAXBContext context = JAXBContext.newInstance(Community.class);
			Marshaller marshaller = context.createMarshaller();
			marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
			
			//muestra XML en consola
			marshaller.marshal(community, System.out);
			//guarda XML en archivo
			marshaller.marshal(community, new FileWriter(".\\src\\Person.xml"));
			 
			
			
   
		    
		    
		    
		    
		    //XML a lista
	        final Unmarshaller unmarshaller = context.createUnmarshaller();	       
	        //final Employee object = (Employee) unmarshaller.unmarshal(new StringReader(stringWriter.toString()));
	        final Community commu = (Community) unmarshaller.unmarshal(new FileReader(".\\src\\Person.xml"));	        	       
	        //System.out.println(commu.toString());
			
			
			
			
			
			
		}catch(Exception e){
			
		}
	}
}